From dffb5078f26236eb97c3942bce0ea139932a736e Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 21 Jul 2015 10:16:15 -0700 Subject: [PATCH] Weed out empty features from the registry It looks like the empty string is leaking in as a feature to all crates being published on crates.io unintentionally. This means that each dependency edge activates the feature `""`. This in turn confuses the resolution process quite a bit, causing it to be far more recursive than it should be. The empty feature, `""`, is weeded out during activation of features but it's never explicitly activated. This means that each new dependency we see has one requested feature (the empty one) with no activated features (as it doesn't have any). This ends up causing us to recurse to attempt to reactivate the dependency. This extreme recursion ended up blowing the stack on some smaller crates and this commit fixes that. --- src/cargo/sources/registry.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/cargo/sources/registry.rs b/src/cargo/sources/registry.rs index 6dfdfcf60..bda2de90e 100644 --- a/src/cargo/sources/registry.rs +++ b/src/cargo/sources/registry.rs @@ -438,6 +438,13 @@ impl<'cfg> RegistrySource<'cfg> { _ => Kind::Normal, }; + // Unfortunately older versions of cargo and/or the registry ended up + // publishing lots of entries where the features array contained the + // empty feature, "", inside. This confuses the resolution process much + // later on and these features aren't actually valid, so filter them all + // out here. + let features = features.into_iter().filter(|s| !s.is_empty()).collect(); + Ok(dep.set_optional(optional) .set_default_features(default_features) .set_features(features) -- 2.30.2